package com.spring.example2.listener;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.spring.example2.MqMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.stereotype.Component;

/**
 * author: chics
 * date: 2025/11/10
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "test-demo-send6", consumerGroup = "demo-test-consumer-group01", messageModel = MessageModel.BROADCASTING)
public class Test3RocketmqListener extends BaseRocketmqListener<JSONObject> {

    @Override
    protected boolean handleMessage(MqMessage<JSONObject> body, MessageExt messageExt) {
        log.info("test3 recevied messgae = "+ JSON.toJSONString(body));
        log.info("test3 recevied messgae = name = "+ body.getBody());
//        int i = 1/0;
        return true;
    }

    @Override
    protected int getMaxRetryCount() {
        return 2;
    }
}
